package edu.ctbu.ljy.bot.util;

import edu.ctbu.ljy.bot.constain.ResultEnum;
import edu.ctbu.ljy.bot.vo.Result;
public class ResultUtils {
    public static Result success(Object data){
        Result result = new Result();
        ResultEnum resultEnum = ResultEnum.SUCCESS;
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        result.setData(data);
        return result;
    }
    public static Result success(){
        return success(null);
    }
    public static Result error(Integer code, String msg){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    public static Result error(ResultEnum resultEnum){
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        return result;
    }
    public static Result error(Object data){
        Result result = new Result();
        ResultEnum resultEnum = ResultEnum.UNKOWN_ERR;
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        return result;
    }
}
